package annotations;

import java.util.List;

/**
 * @Author: DRevelation
 * @Date: 2022/7/6 14:15
 */
public class PasswordUtils {

    @UseCase(id = 47, description = "Password must contain at least one numeric")
    public boolean validatePassword(String password) {
        return password.matches("\\w*\\d\\w*");
    }

    @UseCase(id = 48)
    public String encryptPassword(String password) {
        return new StringBuilder(password).reverse().toString();
    }

    @UseCase(id = 49, description = "New password can't equal previously used ones")
    public boolean checkNewPassword(List<String> prevPasswords, String newPassword) {
        return !prevPasswords.contains(newPassword);
    }
}
